import numpy as np
import pandas as pd
arr=np.random.randint(1,20,size=(3,3))
df= pd.DataFrame(arr,columns=['a','b','c'])
print("原数据：\n",df)
print('每列求和\n',df.agg('sum'))
print("每列求和及平均值聚合\n",df.agg(['sum','mean']))
def rang(arr):
    return arr.max()-arr.min()
print("各行分列求和求平均值合极差聚合\n",df.agg({0:'sum',1:'mean',2:rang},axis=1))